package com.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;



@Configuration
public class WebConfig implements WebMvcConfigurer {
	@Bean
	public FileUploadInterceptor fileUploadInterceptor(){
		return new FileUploadInterceptor();
	}

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		// 自定义拦截器，添加拦截路径和排除拦截路径
		registry.addInterceptor(fileUploadInterceptor())
								.addPathPatterns("/**")
								.excludePathPatterns("/login","/img/**","/dist/**","patient/**","/public/**","/index.html","/subStatic/**","/");
	}

    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");

        registry.addResourceHandler("/public/**").addResourceLocations("classpath:/public/");

    }
//	public void addViewControllers(ViewControllerRegistry registry) {
//		registry.addViewController("/").setViewName("/dist/index.html");
//		registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
//	}


}

